package cc.comac.mom.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.AsrSearchService;
import cc.comac.mom.bean.AsrSearchBean;
import cc.comac.mom.config.OSSService;
import cc.comac.mom.util.ResultBean;

@RestController
@RequestMapping("/QualityAsrSearch")
public class AsrSearchController {

	@Autowired
	private AsrSearchService asrSearchService;
	@Autowired
	private OSSService oSSService;
	@RequestMapping(value = "/selectBySomeFeilds",method = RequestMethod.POST)
	public ResultBean selectBySomeFeilds(@RequestBody AsrSearchBean asrSearch) {
		ResultBean selectBySomeFeilds = asrSearchService.selectBySomeFeilds(asrSearch);
		return selectBySomeFeilds;
	}
	
	@RequestMapping(value = "/exportData", method = RequestMethod.POST)
	public void exportData(HttpServletRequest request, HttpServletResponse response, @RequestBody AsrSearchBean obj) {
		String fileName = "ASR查询数据";
		String url = asrSearchService.exportData(request, response, obj);
		try {
			oSSService.export(response, url, fileName);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}
